#ifndef BASE_LOGGER_H
#define BASE_LOGGER_H
#include "ly_common_sdk_global.h"
#include <string>
#include <memory>
#include <map>
#include <mutex>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/async.h>
#include <boost/filesystem.hpp>

class LY_COMMON_SDK_API base_logger
{
public:
    enum class Mode { Sync, Async };

    // 注册模块的日志器（单例模式，每个模块一个日志器）
    static std::shared_ptr<spdlog::logger>  registerLogger(
        const std::string& module,
        const std::string& log_path,
        const std::string& log_name,
        spdlog::level::level_enum level = spdlog::level::info,
        size_t max_file_size = 10 * 1024 * 1024, // 10MB
        size_t max_files = 3,
        Mode mode = Mode::Sync);

    // 获取指定模块的日志器（单例模式，每个模块一个日志器）
    static std::shared_ptr<spdlog::logger> getLogger(const std::string& name);
private:
    static std::map<std::string, std::shared_ptr<spdlog::logger>> loggers_;
    static std::mutex logger_mutex_;
};

#endif // BASE_LOGGER_H
